package com.jbh.yxjdemobykontlin

import java.util.concurrent.locks.ReentrantLock

class Counter {

    private val lock = ReentrantLock()
    private var count = 0

    fun increment() {
        lock.lock()
        try {
            count++;
        } finally {
            lock.unlock()
        }
    }

    fun getCount(): Int {
        return count
    }
}